import 'package:flutter/material.dart';

void main() => runApp(
      MaterialApp(
        title: '图标及按钮组件示例',
//        home: IconDemo(),
//        home: IconButtonDemo(),
        home: RaisedButtonDemo(),
      ),
    );

class IconDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('图标组件示例'),
      ),
      // 添加图标
      body: Icon(
        // 图标内容
        Icons.phone,
        // 图标颜色
        color: Colors.green[500],
        // 图标大小
        size: 80,
      ),
    );
  }
}

class IconButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('图标按钮组件示例'),
      ),
      body: Center(
        // 添加图标按钮
        child: IconButton(
          // 图标元素
          icon: Icon(
            Icons.volume_up,
            size: 48.0,
          ),
          // 按钮提示
          tooltip: '按下操作',
          // 按下事件响应
          onPressed: () {
            print(' IconButton 被点击 ');
          },
        ),
      ),
    );
  }
}

class RaisedButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'RaisedButton 示例',
      home: Scaffold(
        appBar: AppBar(
          title: Text(' 凸起按钮组件示例 '),
        ),
        body: Center(
          // RaisedButton 具有一种立体感
          child: RaisedButton(
            // 按下事件响应
            onPressed: () {
              // 按下事件处理
              print(' RaisedButton 被点击 ');
            },
            // 添加按钮文本
            child: Text(' RaisedButton 组件 '),
          ),
        ),
      ),
    );
  }
}
